//
//  MDIMainVC.swift
//  MDIWeibo
//
//  Created by 迁徙鸟 on 16/4/16.
//  Copyright © 2016年 qianxiniao. All rights reserved.
//

import UIKit


class MDIMainVC: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = MDITabBar()
        
        
//        tabBar.MDIDelegate = self
        
        setValue(tabBar, forKey: "tabBar")        
        
        addChildViewController(MDIHomeTableVC(),iconName: "tabbar_home",title: "首页")
        addChildViewController(MDIMessageTableVC(),iconName: "tabbar_message_center",title: "消息")
        addChildViewController(MDIDiscoverTableVC(),iconName: "tabbar_discover",title: "发现")
        addChildViewController(MDIProfileTableVC(),iconName: "tabbar_profile",title: "我的")
    }
    
//    MARK - 添加子控制器
    func addChildViewController(childController: UIViewController,iconName : String, title : String) {
        
        childController.tabBarItem.image = UIImage(named: iconName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(iconName)_selected")
        
//        设置title
        childController.title = title
        
//        添加子控制器
        addChildViewController(UINavigationController(rootViewController: childController))
        
    }
}

// extension 相当于分类  后面的MDIMainVC 就代表当前类的分类
extension MDIMainVC : MDITabBarDelegate{
    
    func clickCompose(){
    
    print("撰写按钮被点击啦")
        
    }
}
